<?php

$paginator->options(array('url' => $this->passedArgs));
if(!isset($norace))
    $norace = false;
if(!isset($nocoach))
    $nocoach = false;
?>
<div class="teams">
<h2><?php echo $title?></h2>
<p><?php echo $paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true))); ?></p>
<table cellpadding = "0" cellspacing = "0">
<tr>
	<th><?php echo $paginator->sort(__('Grp',true), 'TeamRanking.iGroup');?></th>
	<th><?php echo $paginator->sort(__('#',true), 'TeamRanking.iRanking');?></th>
	<th><?php echo $paginator->sort(__('Name',true), 'Team.strName');?></th>
	<?php if(!$nocoach) { ?>
	<th><?php echo $paginator->sort(__('Coach',true), 'Team.idCoach');?></th>
	<?php } if(!$norace) { ?>
	<th><?php echo $paginator->sort(__('Race',true), 'Team.idRaces');?></th>
	<?php } ?>
	<th><?php echo $paginator->sort(__('W',true), 'TeamRanking.iWins');?></th>
	<th><?php echo $paginator->sort(__('D',true), 'TeamRanking.iDraws');?></th>
	<th><?php echo $paginator->sort(__('L',true), 'TeamRanking.iLoss');?></th>
	<th><?php echo $paginator->sort(__('Pts',true), 'TeamRanking.iPoints');?></th>
	<th><?php echo $paginator->sort(__('Tv',true), 'TeamRanking.iTeamValue');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($teams as $team):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td><?php echo $team['TeamRanking']['iGroup']; ?></td>
		<td><?php echo $team['TeamRanking']['iRanking']; ?></td>
		<td><?php echo $html->link($team['Team']['strName'], array('controller' => 'teams', 'action' => 'view', $team['Team']['ID'])); ?></td>
		<?php if(!$nocoach) { ?>
		<td><?php echo $html->link($team['Team']['Coach']['strName'], array('controller' => 'coaches', 'action' => 'view', $team['Team']['Coach']['ID'])); ?></td>
		<?php } if(!$norace) { ?>
		<td><?php echo $html->link($team['Team']['Race']['LocalizedString'][$locale], array('controller' => 'races', 'action' => 'view', $team['Team']['Race']['ID'])); ?></td>
		<?php } ?>
		<td><?php echo $team['TeamRanking']['iWins']; ?></td>
		<td><?php echo $team['TeamRanking']['iDraws']; ?></td>
		<td><?php echo $team['TeamRanking']['iLosses']; ?></td>
		<td><?php echo $team['TeamRanking']['iPoints']; ?></td>
		<td><?php echo $team['TeamRanking']['iTeamValue']; ?></td>
	</tr>
<?php endforeach; ?>
</table>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
</div>
